
package GUI;
/* This class will manage the appearence of the screens */

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.plaf.DimensionUIResource;

import Control.*;
import Entity.User;
import qwqw.ClientConsole;

public class ScreenManager extends JFrame {

	
	final public static int DEFAULT_PORT = 2222;
	/** The only instance of the client (singleton) */
	private static ClientConsole client; 
	/** holds a flag for connection */
	public static boolean isFirstTime = true;
	/** Holds the server IP address */	
	//private static String serverIP = new String();
	/** Holds the port */
//	private static int port; 
	/** Holds the privilege level */
//	private int Plevel;
	private static User userName;
	int id;
	String StageName;
	private IPControl ip;
	private IP ip_gui;
	private LoginControl log_in;
	private Login log_in_gui;
	private MainScreen Main_s;
	private AddRequest add_req;
	private AddRequestGui add_req_gui;
	private ViewRequestControl viewReq;
	private ViewRequestGui viewReq_gui;

	private EditRequestGui editReqGui;
	private Edit_Request editReq;
	private EditReqStageMangerControl editStagMan;
	private EditReqStageManagerGui editStagMan_gui;
	private AuthorizationControl auth;;
	private AuthorizationGui AuthMainGui;
	private ReportPanelGUI dis_rep_gui;         //display report button
	private ReportControl dis_rep ;
	private FrozenReqManagControl frozenManagment;
	private FrozenReqManagGui frozenManagGui;
	private DetermineStageManager detStageMang;
	private DetermineStageManagerGui detStageMang_gui;
	private FreezeRequestControl frozen_req;
	private FreezeRequest frozen_req_gui;
	private ExtentionManagControl ExtManControl;
	private ExtentionManagGui ExtManGui;
	private DetermineDuration detStage;
    private DetermineDurationGui detStage_gui;
    private ClosureStageGui stage5_gui;
	private ClosureStageControl stage5_control;
	private EstimationStageGui stage1_gui;
	private EstimationStageControl stage1_control;
	private ExaminationStageGui stage2_gui;
	private ExaminationStageControl stage2_control;
	private PerformanceStageGui stage3_gui;
	private PerformanceStageControl stage3_control;
	private TestingStageGui stage4_gui;
	private TestingStageControl stage4_control;
	private ExtentionStage ext_stage;
	private ExtentionStageGui ext_stage_gui;
	
	/*private ActivityReportControl active_rep;
	private ActivityReportOutputGui active_rep_gui;
	//
	
	
	
	private ReportPanelGUI performance_report_gui;
	private ReportControl  performance_report;
	private ReportPanelGUI create_tardiness_gui;
	private ReportControl create_tardiness;
	private ReportPanelGUI genarate_activity_gui;
	private ReportControl genarate_activity;
	private RegisterNewUserControl  regNewUser;
	private NewUserAuthGui regNewGui;
	private UpdateAuthControl updateAuth;
	private UpdateAuthGui updateAuthGui;
	
	

	
	private ViewRequestOutPut viewReqOutput_gui;
	private DisplayReportControl disRep;
	private DisplayReportGui disRep_gui;
	private TardinessReportControlOutput tarRep;
	private TardinessReportGuiOutput tarRep_gui;
	private EditReqStageManagerGui editStageManagerGui;
	
	
	
	/**
	 * @wbp.parser.entryPoint
	 */
	public ScreenManager(){
		setMinimumSize(new Dimension(516, 600));
		setPreferredSize(new DimensionUIResource(500, 500));
		userName = new User();
		ip= new IPControl();
		log_in= new  LoginControl();
		ip_gui = ip.getIPPanel();
		add(ip_gui);
		setContentPane(ip_gui);
	    setVisible(true);
		Main_s = new MainScreen();
		add_req=new AddRequest();
		editReq = new Edit_Request();
		editStagMan= new EditReqStageMangerControl();
		auth = new AuthorizationControl();
		dis_rep = new ReportControl();
		frozenManagment= new FrozenReqManagControl();
		detStageMang = new DetermineStageManager();
		frozen_req = new FreezeRequestControl();
		detStage = new DetermineDuration();
		ExtManControl= new ExtentionManagControl(); 
		stage5_control = new ClosureStageControl();
		stage1_control = new EstimationStageControl();
		stage2_control = new ExaminationStageControl();
		stage3_control= new PerformanceStageControl();
		stage4_control = new TestingStageControl();
		
		ext_stage = new ExtentionStage();
		//ext_stage_gui = ext_stage.getExt_stage_gui();
    	
		this.Action_listener_operations();
		
		
		

	/*		
		
		
		regNewUser= new RegisterNewUserControl();
		updateAuth= new UpdateAuthControl();
		
		detStageMang = new DetermineStageManager();
		//
		disRep =new DisplayReportControl ();
		viewReq = new ViewRequestControl();
		active_rep = new ActivityReportControl() ;
		tarRep = new TardinessReportControlOutput() ;
	    viewReqOutput_gui = new	ViewRequestOutPut(); */
	}
	
	public static void main(String[] args){
		new ScreenManager();
	}
	
   // public static ClientConsole getClient() {
	//	return client;
  //  }

	public void  Action_listener_operations(){
		
		
		ip_gui.getSubButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String s = ip.ip_entered();
				if(s==null){
					JOptionPane.showMessageDialog(ip_gui, "You have to enter ip number ", "Error", JOptionPane.ERROR_MESSAGE);				
					add(ip_gui);
					setContentPane(ip_gui);
					setVisible(true);
				
				}
				else{
					boolean ans = ip.makeConnection(s);
					if(ans){
					add(log_in_gui);
					setContentPane(log_in_gui);
					setVisible(true);
					}
					else{
						JOptionPane.showMessageDialog(ip_gui, "No conection was established", "Error", JOptionPane.ERROR_MESSAGE);		
						add(ip_gui);
						setContentPane(ip_gui);
						setVisible(true);
					}
				
				
				}
			}
		});
		
		ip_gui.getCanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(ip_gui);
				setContentPane(ip_gui);
			    setVisible(true);
			    
			   	}	
			});
		
	
	    log_in_gui= log_in.getlogInPanel();
		log_in_gui.getSubButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean x=log_in.loginReq_pressed();
				if(x==false){
					add(log_in_gui);
					setContentPane(log_in_gui);
				    setVisible(true);
				}
				 else{
				   add(Main_s);
					setContentPane(Main_s);
					setVisible(true);
				}
			}
		});
		
		log_in_gui.geCanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(Main_s);
				setContentPane(Main_s);
				setVisible(true);
			}
		});
		userName = log_in.getUser();
		
		Main_s.getAddRequestButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add_req_gui = add_req.getAdd_req_gui();
				add(add_req_gui);
				setContentPane(add_req_gui);
			    setVisible(true);	
			}
		});
		
		Main_s.getViewRequestButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				viewReq_gui=viewReq.getV_req();
				add(viewReq_gui);
				setContentPane(viewReq_gui);
			    setVisible(true);	
			}
		});
	
		Main_s.getEditReqButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (userName.getRole().equals("7")){
					editReqGui =editReq.getEditRequestGui(); 
					add(editReqGui);
					setContentPane(editReqGui);
				    setVisible(true);	
				}
				//stage manager
				else if (userName.getRole().equals("0")||userName.getRole().equals("5")||userName.getRole().equals("6")){
					editStagMan_gui = editStagMan.getEditMangerGui();
					add(editStagMan_gui);
					setContentPane(editStagMan_gui);
				    setVisible(true);	
				}
				else
					JOptionPane.showMessageDialog(null, "You are not authorized", "ERROR", JOptionPane.ERROR_MESSAGE);
			       
			}
		});
		
		
		Main_s.getAuthManagButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (userName.getRole().equals("8")){
					AuthMainGui=auth.getAuth_gui();
					add(AuthMainGui);
					setContentPane(AuthMainGui);
					setVisible(true);
				}
				else
					JOptionPane.showMessageDialog(null, "You are not authorized", "ERROR", JOptionPane.ERROR_MESSAGE);
			}
		});
		
		Main_s.getReportsButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (userName.getRole().equals("8")){
					dis_rep_gui=dis_rep.getDisReport();
					add(dis_rep_gui);
					setContentPane(dis_rep_gui);
					setVisible(true);
				}
				else
					JOptionPane.showMessageDialog(null, "You are not authorized", "ERROR", JOptionPane.ERROR_MESSAGE);
			       
			}
		});
		
		Main_s.getFrozenRequestsButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (userName.getRole().equals("8")){
					frozenManagGui = frozenManagment.getFrozenManagGui();
					add(frozenManagGui);
					setContentPane(frozenManagGui);
					setVisible(true);
				}
				else
					JOptionPane.showMessageDialog(null, "You are not authorized", "ERROR", JOptionPane.ERROR_MESSAGE);			
			}
		});
		
		Main_s.getLogOutButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(log_in_gui);
				setContentPane(log_in_gui);
			    setVisible(true);	
			}
		});
		
		add_req_gui=add_req.getAdd_req_gui();
    	add_req_gui.getSubButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.out.print(true);
			boolean x =	add_req.addRequest_pressed();
			if(x==false)
			{
				add(add_req_gui);
				setContentPane(add_req_gui);
			    setVisible(true);	
			}
			else
			{
				add(Main_s);
				setContentPane(Main_s);
				setVisible(true);
			}
		}
    });
		
    	//add_req_gui=add_req.getAdd_req_gui();
    	add_req_gui.getCanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(Main_s);
				setContentPane(Main_s);
			    setVisible(true);	
			}
    	});

		Main_s.getEditReqButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (userName.getRole().equals("7")){
					editReqGui =editReq.getEditRequestGui(); 
					add(editReqGui);
					setContentPane(editReqGui);
				    setVisible(true);	
				}
				//stage manager
				else if (userName.getRole().equals("0")||userName.getRole().equals("5")||userName.getRole().equals("6")){
					editStagMan_gui = editStagMan.getEditMangerGui();
					add(editStagMan_gui);
					setContentPane(editStagMan_gui);
				    setVisible(true);	
				}
				else
					JOptionPane.showMessageDialog(null, "You are not authorized", "ERROR", JOptionPane.ERROR_MESSAGE);
			       
			}
		});
		editReqGui =editReq.getEditRequestGui(); 
		editReqGui.getStagemanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
					detStageMang_gui=detStageMang.getDSMgui();
					add(detStageMang_gui);
					setContentPane(detStageMang_gui);
					setVisible(true);
				
			}
		});
		editReqGui =editReq.getEditRequestGui(); 
		editReqGui.getStagemanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
					detStageMang_gui=detStageMang.getDSMgui();
					add(detStageMang_gui);
					setContentPane(detStageMang_gui);
					setVisible(true);
				
			}
		});
		editReqGui =editReq.getEditRequestGui(); 
		editReqGui.getStagemanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
					detStageMang_gui=detStageMang.getDSMgui();
					add(detStageMang_gui);
					setContentPane(detStageMang_gui);
					setVisible(true);
				
			}
		});
		editReqGui =editReq.getEditRequestGui(); 
		editReqGui.getStagemanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
					detStageMang_gui=detStageMang.getDSMgui();
					add(detStageMang_gui);
					setContentPane(detStageMang_gui);
					setVisible(true);
				
			}
		});
		
		    	
    	editReqGui.getFrozenReqButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frozen_req_gui = frozen_req.getFreezeRequestGui();
				add(frozen_req_gui);
				setContentPane(frozen_req_gui);
			    setVisible(true);
			}
		});
    	
    	editReqGui.getExtentionReqManagButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ExtManGui = ExtManControl.getExtManaGui();
				add(ExtManGui);
				setContentPane(ExtManGui);
			    setVisible(true);
			}
		});
    	
    	editReqGui.getDetermineStageDurationButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				detStage_gui=detStage.getDete_dur();
				add(detStage_gui);
				setContentPane(detStage_gui);
			    setVisible(true);
			}
		});
    	
    	editReqGui.getbtnCloseStagebButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				stage5_gui = stage5_control.getClosureGui();
				add(stage5_gui);
				setContentPane(stage5_gui);
			    setVisible(true);
			}
		});
  
    	editReqGui.getCanbButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(Main_s);
				setContentPane(Main_s);
			    setVisible(true);
			}
		});
    	editStagMan_gui = editStagMan.getEditMangerGui();
    	editStagMan_gui.getUpdateButt().addActionListener(new ActionListener() {	
    		public void actionPerformed(ActionEvent e) {
    			String ReqNum= (String)editStagMan_gui.getReqNum().getSelectedItem();
    			String StageNum= (String)editStagMan_gui.getStageNum().getSelectedItem();
    			if(ReqNum==null ||StageNum==null){
    				JOptionPane.showMessageDialog(null, "Not all fileds are fill  ", "ERROR", JOptionPane.ERROR_MESSAGE);
    			}
    			else {
    				if(StageNum.equals("Estimation")){
    					stage1_control.reqANDstageEntered(ReqNum);
    					stage1_gui = stage1_control.getEstimationGui();
    					add(stage1_gui);
    					setContentPane(stage1_gui);
    					setVisible(true);
    				}
    				if(StageNum.equals("Examination")){
    					stage2_control.reqANDstageEntered(ReqNum);
    					stage2_gui =stage2_control.getExaminationGui();
    					add(stage2_gui);
    					setContentPane(stage2_gui);
    					setVisible(true);
    				}
    				if(StageNum.equals("Performance")){
    					stage3_control.reqANDstageEntered(ReqNum);
    					stage3_gui =stage3_control.getPerformanceGui();
    					add(stage3_gui);
    					setContentPane(stage3_gui);
        		    	setVisible(true);
    				}
    				if(StageNum.equals("Testing")){
    					stage4_control.reqANDstageEntered(ReqNum);
    					stage4_gui =stage4_control.getTextingGui();
    					add(stage4_gui);
    					setContentPane(stage4_gui);
    					setVisible(true);
    				}	
    			}
    		}
    	});
    	
    	editStagMan_gui.getExtentionRequestButt().addActionListener(new ActionListener() {	
    		public void actionPerformed(ActionEvent e) {
    			id= Integer.parseInt((String)editStagMan_gui.getReqNum().getSelectedItem());
    			 StageName= (String)editStagMan_gui.getStageNum().getSelectedItem();
    			if(id==0 ||StageName==null){
    				JOptionPane.showMessageDialog(null, "Not all fileds are fill  ", "ERROR", JOptionPane.ERROR_MESSAGE);
    			}
    			else{
    				//ext_stage.reqANDstageEntered(ReqNum, StageNum);
    				ext_stage_gui = ext_stage.getExt_stage_gui();
    				add(ext_stage_gui);
					setContentPane(ext_stage_gui);
					setVisible(true);	
    			}
    			
    		}
    
	});
    	ext_stage_gui = ext_stage.getExt_stage_gui();
    	ext_stage_gui.getSubmitBott().addActionListener(new ActionListener() {	
    		public void actionPerformed(ActionEvent e) {
    			
    				Boolean ans = ext_stage.extSubb_pressed(id, StageName);
    				if(ans){
    					add(Main_s);
    					setContentPane(Main_s);
    				    setVisible(true);
    				}
    				else{
    					ext_stage_gui = ext_stage.getExt_stage_gui();
        				add(ext_stage_gui);
    					setContentPane(ext_stage_gui);
    					setVisible(true);	
        			}	
    		}
    
	});
    	editStagMan_gui.getCanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(Main_s);
				setContentPane(Main_s);
			    setVisible(true);
			}
		});
    	ext_stage_gui.getCancelBott().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(Main_s);
				setContentPane(Main_s);
			    setVisible(true);
			}
		});
    		
    		
		/* viewReqOutput_gui.getButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(Main_s);
				setContentPane(Main_s);
			    setVisible(true);	
			}
		});
		
		
		
		
    	frozen_req_gui=frozen_req.getFreezeRequestGui();
    	frozen_req_gui.getSubButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean x=frozen_req.submit_press();
				if(x==false){
					add(frozen_req_gui);
					setContentPane(frozen_req_gui);
				    setVisible(true);
				}
				else{
					add(Main_s);
					setContentPane(Main_s);
				    setVisible(true);
				}
				
			}
    	});
    	frozen_req_gui.getCanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(Main_s);
				setContentPane(Main_s);
			    setVisible(true);
			}
    	});
    	
    
    	
    	AuthMainGui=new AuthorizationGui();
    	AuthMainGui.getAddNewButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(regNewGui);
				setContentPane(regNewGui);
			    setVisible(true);
			}
    	});

    	AuthMainGui.getUpdateButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(updateAuthGui);
				setContentPane(updateAuthGui);
			    setVisible(true);
			}
    	});
    	
    	AuthMainGui.getCancelbutton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(Main_s);
				setContentPane(Main_s);
			    setVisible(true);
			}
    	});
    	
    	regNewGui= regNewUser.getnewUserPanel();
		regNewGui.getSubButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean x=regNewUser.registerNewUser_pressed();
				if (x==false){
					add(regNewGui);
					setContentPane(regNewGui);
				    setVisible(true);
				}
				else{
					add(Main_s);
					setContentPane(Main_s);
				    setVisible(true);
				}
			}
		});
		
		regNewGui.getCanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(AuthMainGui);
				setContentPane(AuthMainGui);
			    setVisible(true);
			}
		});
		
		
		updateAuthGui= updateAuth.getUpAuthGui();
		updateAuthGui.getSubButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			boolean x = updateAuth.updateAuthorization_pressed();
			if (x == false){
				add(updateAuthGui);
				setContentPane(updateAuthGui);
			    setVisible(true);
			}
			add(Main_s);
			setContentPane(Main_s);
		    setVisible(true);
			
			}
		});
		
		updateAuthGui.getCanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
	    		add(AuthMainGui);
				setContentPane(AuthMainGui);
			    setVisible(true);	
			}
		});
		
		frozenManagGui=frozenManagment.getFrozenManagGui();
		frozenManagGui.getSubButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			boolean x =frozenManagment.frozenReqManagment_pressed();
			if(x==false){
				add(frozenManagGui);
				setContentPane(frozenManagGui);
			    setVisible(true);
			}
			else{
				add(Main_s);
				setContentPane(Main_s);
			    setVisible(true);	
			}
			}
		});
		
		frozenManagGui=frozenManagment.getFrozenManagGui();
		frozenManagGui.getcanButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(Main_s);
				setContentPane(Main_s);
			    setVisible(true);	
			}
		});
		
		ExtManGui= ExtManControl.getExtManaGui();
		ExtManGui.getEnterButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean x = ExtManControl.enter_pressed();
				if (x==false){
					add(ExtManGui);
					setContentPane(ExtManGui);
				    setVisible(true);	
				}
				else{
					//add the out put on the gui screen
					add(ExtManGui);
					setContentPane(ExtManGui);
				    setVisible(true);	
					
				}
				
				
				
			}
		});
		
		ExtManGui= ExtManControl.getExtManaGui();
		ExtManGui.getSubButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean x = ExtManControl.enter_pressed();
				if (x==false){
					add(ExtManGui);
					setContentPane(ExtManGui);
				    setVisible(true);	
				}
				else{
					add(Main_s);
					setContentPane(Main_s);
				    setVisible(true);
					
				}
			}
		});
		
		ExtManGui= ExtManControl.getExtManaGui();
		ExtManGui.getcanButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(editReqGui);
				setContentPane(editReqGui);
			    setVisible(true);
			}
		});
		
		ext_stage_gui = ext_stage.getExt_stage_gui();
    	ext_stage_gui.getSubmitBott().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ext_stage.extSubb_pressed();
			}
    	});
		
    	ext_stage_gui = ext_stage.getExt_stage_gui();
    	ext_stage_gui.getCancelBott().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(editStageManagerGui);
				setContentPane(editStageManagerGui);
			    setVisible(true);
			}
    	});
    	
    	stage1_gui= stage1_control.getEstimationGui();
    	stage1_gui.getSubButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				stage1_control.estimation_Submit_pressed();
			}
    	});
		
    	stage1_gui.getCanButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(editStageManagerGui);
				setContentPane(editStageManagerGui);
			    setVisible(true);
			}
    	});
		
    	stage2_gui=stage2_control.getExaminationGui();
    	stage2_gui.getSubButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				stage2_control.examination_Submit_pressed();
			}
    	});
    	
    	stage2_gui.getcanButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(editStageManagerGui);
				setContentPane(editStageManagerGui);
			    setVisible(true);
			}
    	});
		
    	stage3_gui=stage3_control.getPerformanceGui();
    	stage3_gui.getSubButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				stage3_control.performance_Submit_pressed();
			}
    	});
		
    	stage3_gui.getcanButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(editStageManagerGui);
				setContentPane(editStageManagerGui);
			    setVisible(true);
			}
    	});
   
    	stage4_gui=stage4_control.getTextingGui();
    	 stage4_gui.getSubButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			boolean x =	stage4_control.testing_Submit_pressed();
			if(x == false){
				add(stage4_gui);
				setContentPane(stage4_gui);
			    setVisible(true);
			}
			else{
			add(Main_s);
			setContentPane(Main_s);
		    setVisible(true);	
			}	
			}
    	});
	
    	stage4_gui.getcanButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(editStageManagerGui);
				setContentPane(editStageManagerGui);
			    setVisible(true);
			}
    	});
    	
    	stage5_gui=stage5_control.getClosureGui();
    	stage5_gui.getSubButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean x= stage5_control.closure_Submit_pressed();
				if(x==false){
					add(stage5_gui);
	       			setContentPane(stage5_gui);
				    setVisible(true);
				}
				else{
					add(editReqGui);
					setContentPane(editReqGui);
				    setVisible(true);	
				}
				
			}
    	}); 
    	
    	stage5_gui.getcanButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(editReqGui);
				setContentPane(editReqGui);
			    setVisible(true);
			}
    	});
    	
    	
    	detStageMang_gui= detStageMang.getDSMgui();
    	detStageMang_gui.getSubBtn().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				detStageMang.submitBnt_prassed();
			}
		});
    	
    	detStageMang_gui.getCanBtn().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				add(editReqGui);
				setContentPane(editReqGui);
			    setVisible(true);
			}
		});
    	
    	detStage_gui=detStage.getDete_dur();
    	detStage_gui.getSubBtn().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				detStage.submit_pressed();
			}
		});
    	
    	detStage_gui.getCancelBtn().addActionListener(new ActionListener() {
    		public void actionPerformed(ActionEvent e) {
    			add(editReqGui);
    			setContentPane(editReqGui);
    		    setVisible(true);
    		}
    	});
    
    	
    	
    	
    	
    	
    	
    	
    	
    dis_rep_gui = dis_rep.getDisReport();
    dis_rep_gui.getBtnDisplayReport_1().addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			dis_rep.displayReport_pressed2(OP_CODE.DISPLAY_REPORT);//send the op-code to the fun
			add(disRep_gui);
			setContentPane(disRep_gui);
		    setVisible(true);	

		}
	});

   dis_rep_gui = dis_rep.getDisReport();
    dis_rep_gui.getBtnCreatePerformanceReport_1().addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			boolean x = dis_rep.PerformanceReport_pressed(OP_CODE.PERFORMANCE_REPORT);
			if(x==true)
			{
			add(performance_report_gui);
			setContentPane(performance_report_gui);
		    setVisible(true);	
			}
			if (x==false)
			{
				add(dis_rep_gui);
			setContentPane(dis_rep_gui);
		    setVisible(true);	
			}
		}
	});
   dis_rep_gui = dis_rep.getDisReport();
    dis_rep_gui.getBtncreateTardinessReport().addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
	boolean	x =	dis_rep.TardinessReport_pressed(OP_CODE.TARDINESS_REPORT);
		if(x==true)
		{
			add(tarRep_gui);
			setContentPane(tarRep_gui);
		    setVisible(true);
		}
		if (x==false)
		{
		add(dis_rep_gui);
		setContentPane(dis_rep_gui);
	    setVisible(true);	
		}
	
		}
	});
    dis_rep_gui = dis_rep.getDisReport();
    dis_rep_gui.getBtncreateActivityReport().addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			boolean x = dis_rep.ActivityReport_pressed(OP_CODE.ACTIVITY_REPORT);
			if(x==true)
			{
				add(active_rep_gui);
				setContentPane(active_rep_gui);
			    setVisible(true);
			}
			if (x==false)
			{
			add(dis_rep_gui);
			setContentPane(dis_rep_gui);
		    setVisible(true);	
			}
		}
	});
	
		viewReq_gui=viewReq.getV_req();
	viewReq_gui.getbtnSubmit().addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		boolean x =	viewReq.Submit_pressed();
		if(x==true)
		{
			add(viewReqOutput_gui);
			setContentPane(viewReqOutput_gui);
		    setVisible(true);
		}
		if (x==false)
		{
		add(viewReq_gui);
		setContentPane(viewReq_gui);
	    setVisible(true);	
		}
			
		}
});
	
	viewReq_gui=viewReq.getV_req();
	viewReq_gui.getBtnCansel().addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			add(Main_s);
			setContentPane(Main_s);
		    setVisible(true);
		}
});
	
	disRep_gui = disRep.getDis_rep();
	disRep_gui.getSubButton().addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			detStage.submit_pressed();
		}
	});
	disRep_gui = disRep.getDis_rep();
	disRep_gui.getCanButt().addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			add(Main_s);
			setContentPane(Main_s);
		    setVisible(true);	
				
		}
	});
/active_rep_gui = active_rep. getActive_rep();
	active_rep_gui.getButton().addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			add(Main_s);
			setContentPane(Main_s);
		    setVisible(true);	
				
		}
	});
	
	tarRep_gui = tarRep.getTar_rep_gui();
	tarRep_gui.getCancelButton().addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			add(Main_s);
			setContentPane(Main_s);
		    setVisible(true);	
				
		}
	});
	}
	
	
<<<<<<< .mine
	private void getConnection(String s)
=======
	}
	/**
	* Get the only singleton connection
	* This method is read with initial parameters
	* @param host The host to connect to.
	* @param port The port to connect to.
	*/
    	}
	public static ClientConsole getConnection(String s, int port)

	{
		if(client== null){
			client = new ClientConsole(s, port);
		}
		return client;
		
	}
    	
	/**
	* Get the only singleton connection
	* This method is read without parameters
	* so the connection is the same as before
	*/
	public static ClientConsole getConnection() {
		return client;
	}
	
	public static User getUserName(){
		return userName;
	}
    	
}
	